#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	vector<int> a(n + 1), b(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) cin >> b[i];
	int x1 = 0, x2 = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] > b[i]) x1++;
		else if (a[i] < b[i]) x2++;
	}
	cout << x1 << " " << x2 << endl;
	if (x1 > x2) cout << "S" << endl;
	else if (x1 < x2) cout << "Q" << endl;
	else cout << "Tie" << endl;
	return 0;
}